﻿using WeiXinPF.Templates;
using System;
using System.Collections.Generic;
using WeiXinPF.Common;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OneGulp.WeChat.MP.AdvancedAPIs;
using OneGulp.WeChat.MP.AdvancedAPIs.OAuth;

namespace WeiXinPF.Web.weixin.pano360
{
    public partial class detail : TravelBasePage
    {

        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (errInitTemplates != "")
            {
                Response.Write(errInitTemplates);
                return;
            }

            //1获得模版基本信息
            BLL.wx_templates tBll = new BLL.wx_templates();
            templateFileName = tBll.GetTemplatesFileNameByWid(wid);
            if (templateFileName == null || templateFileName.Trim() == "")
            {
                errInitTemplates = "不存在该帐号或者该帐号尚未设置模版！";
                Response.Write(errInitTemplates);
                Response.End();
                return;
            }

            //授权
            string openid = MyCommFun.RequestOpenid();
            serverPath = MyCommFun.GetRootPath() + "weixin/pano360/templates/normal/detail.html";
            int categoryid = new BLL.advertisement().GetCateGoryIDbyName("travel");
            TravelTemplate template = new TravelTemplate("weixin/pano360/templates/", serverPath, wid, categoryid);
            template.tType = TemplateType.News;
            //template.openid = MyCommFun.RequestOpenid();
            template.openid = openid;
            template.OutPutHtml(templateFileName,wid);
        }
    }
}